var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/work-flow/WFlowFeedBackWin.tsx
var WFlowFeedBackWin_exports = {};
__export(WFlowFeedBackWin_exports, {
  WFlowFeedBackWin: () => WFlowFeedBackWin
});
module.exports = __toCommonJS(WFlowFeedBackWin_exports);
var import_react = require("react");
var import_org_tree = require("../org-tree");
var import_util = require("./util");
var import_util2 = require("../../util");
var import_functionalComponent = require("../../functionalComponent");
var import_configComponent = require("../../configComponent");
var columnProps = {
  sortable: false,
  resizable: false,
  columnSort: false,
  tooltip: true
};
function WFOrgHelp({ tableRef, ...props }) {
  const params = (0, import_react.useMemo)(() => {
    return { orgattr: "18", isRight: false };
  }, []);
  const onDataLoad = (0, import_util2.useRefCallback)((nodes) => {
    nodes.push({
      title: import_util.NGLang.noDeptData,
      isLeaf: true,
      id: "0.1",
      key: "0.1",
      OCode: "$ljb$"
    });
    return nodes;
  });
  return /* @__PURE__ */ React.createElement(import_org_tree.OrgTree, { params, defaultSelectedFirstNode: true, dataLoad: onDataLoad, ...props });
}
async function getFeedBackUser(params = {}) {
  const resp = await import_util2.iup.request.get({
    url: "WorkFlow3/WorkFlow/GetFeedBackUserByPage",
    data: { limit: 25, page: 0, ...params }
  });
  resp.Record = resp.Record.map((r) => {
    return { UserNo: r.userNo, UserName: r.userName, ...r };
  });
  return resp;
}
var NGFeedBackUserHelp = (props) => {
  const { ...others } = props;
  others.contentParams = {};
  others.onBeforeOpen = (0, import_util2.useRefCallback)(async () => {
    const { Record: record } = await getFeedBackUser();
    const right = [
      {
        ...columnProps,
        header: import_util.NGLang.userNo,
        flex: 1,
        dataIndex: "UserNo"
      },
      {
        ...columnProps,
        header: import_util.NGLang.userName,
        flex: 1,
        dataIndex: "UserName"
      }
    ];
    const commonParam = {
      valueField: "UserNo",
      labelField: (r) => `${r.UserName}(${r.UserNo})`
    };
    if (record.length > 0) {
      return {
        request() {
          return { total: record.length, record };
        },
        helpTitle: import_util.NGLang.selectpsn,
        columns: {
          left: [
            ...right,
            {
              ...columnProps,
              header: import_util.NGLang.userDept,
              flex: 2,
              dataIndex: "deptName"
            },
            {
              ...columnProps,
              header: import_util.NGLang.userOrg,
              flex: 3,
              dataIndex: "orgName"
            }
          ],
          right
        },
        ...commonParam
      };
    } else {
      return {
        FilterTree: WFOrgHelp,
        request: async ({ pageIndex, pageSize, keyword, treeNodes }) => {
          const data = {
            hasright: false,
            filterUserPhid: "",
            page: pageIndex - 1,
            start: (pageIndex - 1) * pageSize,
            limit: pageSize
          };
          keyword && (data.gobelfilter = encodeURI(encodeURI(keyword)));
          if (treeNodes && treeNodes.length > 0) {
            data.queryfilter = { DeptId: treeNodes[0].id };
            data.OCode = treeNodes[0].OCode;
          }
          const resp = await import_util2.iup.request.body({ url: "HR/Emp/User/GetUserList", data });
          return { total: resp.data.totalRows, record: resp.data.Record };
        },
        autoLoad: false,
        helpTitle: import_util.NGLang.operatorHelp,
        columns: right,
        ...commonParam
      };
    }
  });
  return /* @__PURE__ */ React.createElement(import_functionalComponent.BaseHelp, { modal: true, multiple: true, input: false, allowClear: false, ...others });
};
var formConf = [
  { label: import_util.NGLang.FeedBackTitle, required: true, name: "title", xtype: "NGInput" },
  { label: import_util.NGLang.FeedBackReceive, required: true, name: "receiveuser", xtype: NGFeedBackUserHelp },
  { label: import_util.NGLang.FeedBackMsg, required: true, name: "msg", xtype: "TextArea", autoSize: { minRows: 4, maxRows: 6 } }
];
function WFlowFeedBackWin({ workFlowInfo }) {
  const [values, setValues] = (0, import_util2.useRefState)({ title: "流程反馈消息", receiveuser: [], msg: "" });
  const mCtx = (0, import_react.useContext)(import_functionalComponent.ModalContext);
  const formRef = (0, import_util2.useApi)();
  const invokeOkHandler = (0, import_util2.useRefCallback)(async () => {
    var _a;
    const api = (_a = formRef.current) == null ? void 0 : _a.getApi();
    try {
      const formValues = await api.validateForm();
      const mst = api.getFormatValues();
      mst.form.newRow.receiveusercode = mst.form.newRow.receiveuser;
      mst.form.newRow.receiveuser = formValues.receiveuser.map((v) => v.label).join("");
      const resp = await import_util2.iup.request.get({
        url: "WorkFlow3/WorkFlow/SaveFeedBack",
        data: {
          piid: workFlowInfo.wfpiid,
          mststore: mst
        }
      });
      if (resp.code === 0) {
        await (0, import_util.wfAlert)(import_util.NGLang.alertTitle, import_util.NGLang.sendSuccess);
        mCtx.ins.destroy();
      } else {
        await (0, import_util.wfAlert)(import_util.NGLang.alertTitle, import_util.NGLang.sendError);
      }
    } catch (e) {
      console.log(e);
    }
  });
  (0, import_react.useEffect)(() => {
    getFeedBackUser({ rtntype: 1 }).then(({ Record: users }) => {
      if (users.length > 0) {
        setValues((prev) => {
          return {
            ...prev,
            receiveuser: users.map((user) => {
              const { UserNo, UserName } = user;
              return { value: UserNo, label: `${UserName}(${UserNo})`, origin: user };
            })
          };
        });
      }
    });
    mCtx.ins.setApi({ invokeOkHandler });
  }, []);
  return /* @__PURE__ */ React.createElement(import_util2.Layout, { style: { height: 300, padding: "15px 5px 0 5px" } }, /* @__PURE__ */ React.createElement(import_configComponent.Form, { ref: formRef, opt: "newRow", defaultValue: values, colspan: 1, config: formConf }));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  WFlowFeedBackWin
});
